home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 011 / lptreset.arc / LPTRESET.C next >
Text File  |  1987-05-12  |  2KB  |  87 lines

  1. /*    Last revision: May 12, 1987 at 17:36  */
  2.  
  3. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  4. /*                                                                                                    */
  5. /* Program lptreset                                                                            */
  6. /*                                                                                                    */
  7. /* usage: lptreset [printer] where                                                        */
  8. /*        Optional printer is 1, 2 or 3 for LPT1:, LPT2: or LPT3:                */
  9. /*        Default resets LPT1:                                                            */
  10. /*                                                                                                 */
  11. /*     Initialize LPT1:, LPT2: or LPT3:.                                                */
  12. /*     Return ERRORLEVEL 0 if ok, 1 if failure, which either means a bad        */
  13. /* command line or (probably) the printer is off line.                            */
  14. /*                                                                                                 */
  15. /*     Compiled with Lattice C, Version 3.10                                            */
  16. /*                                                                                                    */
  17. /* Lew Paper                                                                                    */
  18. /* Copyright (c) 1987 Lew Paper                                                            */
  19. /*                                                                                                    */
  20. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  21.  
  22. #include <stdio.h>
  23. #include <dos.h>
  24.  
  25. static char copyrit[] = "Copyright (c) 1987 Lew Paper\n\n";
  26.  
  27. void usage()
  28.  
  29. {
  30.     fputs("usage: lptreset [printer] where\n", stderr);
  31.     fputs("        Optional printer is 1, 2 or 3 for LPT1, LPT2 or LPT3\n",
  32.            stderr);
  33.     fputs("        Default resets LPT1:\n", stderr);
  34.     fputs(copyrit, stderr);
  35.     exit(1);
  36. }
  37.  
  38. main(argc, argv)
  39.     int argc;
  40.     char *argv[];
  41.  
  42. {
  43.  
  44.     int printer;
  45.     union REGS reg;
  46.  
  47.     switch (argc)
  48.     {
  49.         case 1:
  50.             printer = '1';
  51.             break;
  52.         case 2:
  53.             switch (*argv[1])
  54.             {
  55.                 case '1':
  56.                 case '2':
  57.                 case '3':
  58.                     printer = *argv[1];
  59.                     break;
  60.                 default:
  61.                     usage();
  62.                     break;
  63.             }
  64.         break;
  65.         default:
  66.             usage();
  67.             break;
  68.     }
  69.  
  70.     reg.h.ah = 1;
  71.     reg.x.dx = printer - '1';
  72.     (void) int86(0x17, ®, ®);
  73.     if(reg.h.ah & 0x10)
  74.     {
  75.         fprintf(stderr, "Initialized LPT%c: Printer Port\n%s", printer,
  76.                   copyrit);
  77.         exit(0);
  78.     }
  79.     else
  80.     {
  81.         fprintf(stderr, "Unable to initialize LPT%c: Printer Port\n%s",
  82.                    printer, copyrit);
  83.         exit(1);
  84.     }
  85. }
  86.  
  87.